<?php
/**
 * Created by PhpStorm.
 * User: yiduan
 * Date: 2019/2/15 0015
 * Time: 14:34
 */
namespace app\app\controller;
use think\Db;

class User extends Common{

    function __construct(\think\App $app = null)
    {
        $this->requestType = 'post';
        parent::__construct($app);
    }

    function index(){
        $date = date('Y-m-d');
        $tp = $this->getPgData('tp', 'tv');

        if($list = Db::name('yoo_user')
            ->where("tp='$tp'")
            ->where(function ($query) use($date){
                $query->where('updateDate', 'lt' , $date)->whereNull('updateDate', 'or');
            })->select()){
//            return Db::name('yoo_user')->getLastSql();

            return json_encode($list);
        }
        return json_encode([]);
    }

    function upUDate(){
        $id = $this->getPgData('id');
        $date = date('Y-m-d');

        Db::name('yoo_user')->where("id=$id")->setField('updateDate',$date);
        echo 1;
    }


}